package com.bigdata

import java.util.Properties

import com.bigdata.common.constants.Constants
import com.bigdata.common.utils.KafkaCommonUtils
import com.bigdata.common.utils.KafkaCommonUtils.produceMockData
import org.apache.kafka.clients.producer.{KafkaProducer, ProducerRecord}

import scala.util.Random

object KafkaProducer {

  def main(args: Array[String]): Unit = {
    writeToKafka(Constants.Topic_Item)
  }

  def writeToKafka(topic: String): Unit = {
    val producer = KafkaCommonUtils.createKafkaProducer(topic)
    val bufferedSource = io.Source.fromFile(".\\HotItemsAnalysis\\src\\main\\resources\\UserBehavior.csv")
    for (line <- bufferedSource.getLines) {
      val record = new ProducerRecord[String, String](topic, line)
      producer.send(record)
    }
    producer.close()
  }
}